from django.http import HttpResponse
from datetime import datetime
from django.shortcuts import render
from django.views import View
from article.models import Article, User

def article_list(request):
    # return HttpResponse('article_list函数')
    articles = Article.objects.all()
    return render(request,'article_list.html',{"articles":articles})

def year_archive(request, year):
    return HttpResponse(f'year_archive函数接收参数year:{year}')

def month_archive(request, year, month):
    return HttpResponse(f'month_archive函数接收参数year:{year},month:{month}')

def article_detail(request,year,month,slug):
    return HttpResponse(f'article_detail函数接收参数year:{year},month:{month},slug:{slug}')

def get_current_datetime(request):
    today = datetime.today()
    formatted_today = today.strftime('%y-%m-%d')
    html = f"<html><body>今天是 {formatted_today}</body></html>"
    return HttpResponse(html)


# class ArticleForm(View):
#     def get(self, request, *args, **kwargs):
#         return HttpResponse("返回GET请求响应")